package com.itqf.controller.exception;

import com.itqf.utils.R;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2021/1/28
 * @Time: 下午2:52
 */
@ControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public R  exception(Exception e){
        e.printStackTrace();
        return  R.error(e.getMessage());
    }

    @ExceptionHandler(UnauthorizedException.class)
    @ResponseBody
    public R  unauthorizedException(UnauthorizedException e){
        e.printStackTrace();
        return  R.error("没有权限访问，请联系管理员");
    }


}
